(function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })(); EOL.namespace('jobHistory'); EOL.jobHistory.initiated = false; EOL.jobHistory.cacheEnabled = false; EOL.jobHistory.userid; EOL.jobHistory.catid; EOL.jobHistory.filterTime = ''; EOL.jobHistory.sixmonthLimit = 0; EOL.jobHistory.filterCategory = ''; EOL.jobHistory.filterSubCategory = ''; EOL.jobHistory.filterRating = ''; EOL.jobHistory.filterRatingLow = 0; EOL.jobHistory.filterRatingUp = 5; EOL.jobHistory.filterStatus = ''; EOL.jobHistory.filterSearch = ''; EOL.jobHistory.sort = ''; EOL.jobHistory.sortOrder = ''; EOL.jobHistory.keywordSearch = ''; EOL.jobHistory.keywordSearchOn = false; EOL.jobHistory.keywordCount = 0; EOL.jobHistory.numJobDisplayed = 0; EOL.jobHistory.numJobAvailable = 0; EOL.jobHistory.numJobTotal = 0; EOL.jobHistory.hasAllJobs = false; EOL.jobHistory.jobList = new Array(); function Job(id, order){ function display(setting){ this.display = setting; } function getJobid(){ return this.id; } this.id = id; this.order = order; this.display = true; this.tdate = null; this.category = null; this.ratings = null; this.keyword = null; } EOL.jobHistory.getFilterNSort = function(){ var filter = ''; if(EOL.jobHistory.filterCategory){ filter += '&c='+EOL.jobHistory.filterCategory } if(EOL.jobHistory.filterSubCategory){ if(EOL.jobHistory.filterCategory){ filter += '&sc='+EOL.jobHistory.filterSubCategory; } else { filter += '&c='+EOL.jobHistory.filterSubCategory; } } if(EOL.jobHistory.filterTime ){ filter += '&t=1' } if(EOL.jobHistory.filterRating) { filter += '&r='+EOL.jobHistory.filterRating; } if(EOL.jobHistory.filterSearchOn && $('pastjob_search').value){ filter += '&k='+escape($('pastjob_search').value); } if(EOL.jobHistory.sort){ filter += '&s='+EOL.jobHistory.sort; filter += '&o='+EOL.jobHistory.sortOrder; } if (EOL.jobHistory.filterStatus) { filter += '&st='+EOL.jobHistory.filterStatus; } EOL.jobHistory.hasEveryJobs(); return filter; } EOL.jobHistory.hideSubcategory = function(catid) { if(catid) { $('subcat_filter').href = "javascript:EOL.jobHistory.showMenu('filterSubCategory')"; } var catids = new Array(10178,10179,10180,10183,10184,10186,10187,14000); for(i=0;i 1; } EOL.jobHistory.hasEveryJobs = function() { if(EOL.jobHistory.hasAllJobs) return true; if(parseInt(EOL.jobHistory.numJobTotal) <= parseInt(EOL.jobHistory.numJobAvailable)){ EOL.jobHistory.hasAllJobs = true; } else { } return EOL.jobHistory.hasAllJobs; } EOL.jobHistory.searchKeyword = function(){ EOL.jobHistory.filterSearchOn = true; if($('pastjob_search').value == 'Search past jobs (in last 12 mos)'){ $('pastjob_search').value = ''; } EOL.jobHistory.redirectToPage(); } EOL.jobHistory.clearSearch = function(redirect){ $('pastjob_search').value = ''; EOL.jobHistory.filterSearchOn = false; if(redirect) EOL.jobHistory.redirectToPage(); } EOL.jobHistory.redirectToPage = function(){ var filters = EOL.jobHistory.getFilterNSort(); var parameters = $('job_url').value; filters = filters.replace(/^&/,''); if(filters){ parameters += '?' + filters; if(EOL.jobHistory.filterSearchOn) parameters += '#search'; } window.location = parameters; } EOL.jobHistory.initiateJobHistory = function() { if($('catid')) EOL.jobHistory.filterCategory = $('catid').value; if($('subcatid')) EOL.jobHistory.filterSubCategory = $('subcatid').value; if($('subcat_filter') && $('category_filter')){ EOL.jobHistory.hideSubcategory($('category_filter').value); } EOL.jobHistory.filterTime = $('time_filter').value; EOL.jobHistory.filterRating = $('rating_filter').value; EOL.jobHistory.sort = $('sort').value; EOL.jobHistory.sortOrder = $('order').value; EOL.jobHistory.numJobAvailable = $('project_available').value; if($('project_total') && $('project_total').value > 0){ EOL.jobHistory.cacheEnabled = true; EOL.jobHistory.numJobTotal = $('project_total').value; } for(var index=0; index < EOL.jobHistory.numJobAvailable; index++){ id = $('ec_'+index+'_jobid').value; currentJob = new Job(id, index); if(EOL.jobHistory.cacheEnabled) { if($('ec_' + index + '_date')) currentJob.tdate = $('ec_' + index + '_date').value; if($('ec_' + index + '_ratings')) currentJob.ratings = $('ec_' + index + '_ratings').value; if($('ec_' + index + '_catid')) currentJob.category = $('ec_' + index + '_catid').value; } EOL.jobHistory.jobList.push(currentJob); } EOL.jobHistory.initiated = true; if($('keyword').value) { $('pastjob_search').value = $('keyword').value; EOL.jobHistory.highlightKeywords(); EOL.jobHistory.showAllJobDetails(true); } else if($('keywordCountShown').value) { if($('noresults_text')) //provider $('noresults_text').innerHTML = $('keywordCountShown').value + " results found"; else if($('noresults')) //buyer $('noresults').innerHTML = $('keywordCountShown').value + " results found"; $('noresults').removeClass('displayNone'); } EOL.jobHistory.userid = $('userid').value; EOL.jobHistory.catid = $('catid').value; EOL.jobHistory.numJobDisplayed = $('project_displayed').value; EOL.jobHistory.expandJobHistoryIfRequested(); $$('div.jobhistory').addEvents({ 'mouseover': function(){ if (this.getElement('div.shareFeedback')) { this.getElement('div.shareFeedback').removeClass('displayNone'); } }, 'mouseleave': function(){ if ( this.getElement('div.shareFeedback') ) { this.getElement('div.shareFeedback').addClass('displayNone'); this.getElement('div.shareFeedback-dialog').addClass('displayNone'); } } }); $$('div.share-button').addEvent('click', function() { var sharedMenu = this.getParent().getParent().getElement('div.shareFeedback-dialog'); if ( sharedMenu.hasClass('displayNone') ) { sharedMenu.removeClass('displayNone'); } else { sharedMenu.addClass('displayNone'); } }); } EOL.jobHistory.sortResults = function() { EOL.jobHistory.redirectToPage(); } EOL.jobHistory.filterResults = function() { if(!EOL.jobHistory.manipulateJobs()) return; var numJobs = EOL.jobHistory.jobList.length; var inlist = false; for(var j=0; j parseInt(EOL.jobHistory.filterRatingUp) || parseInt(jobInfo.ratings) < parseInt(EOL.jobHistory.filterRatingLow)){ filter = true; } return filter; } EOL.jobHistory.clickAwayMenu = function(event) { var el = null; if(window.event) el = window.event.srcElement; else el = (event.target.tagName) ? event.target : event.target.parentNode; do { if(el.id == 'filterRating' || el.id == 'filterCategory' || el.id == 'filterSubCategory' || el.id == 'filterTime' || el.id == 'sortJob') return } while (el = el.parentNode); EOL.jobHistory.hideAllMenu(); } EOL.jobHistory.showSubcategoryMenu = function(catid) { if(!catid) catid = ''; $('filterCategory').innerHTML = ''; var path = '/php/profile/main/providerServices.php?'; var options = { url: path + 'userid=' + $('userid').value + '&catid=' + catid + '&t=' + getDateTime(), method: 'get', onSuccess: function(response) { var data = JSON.decode(response); var container = new Element('div', {'class':'actionMenuItem'}); var menuItem = new Element('ul').inject(container); for(var i=0; i 0){ $('keyword_count').innerHTML = $('keywordCountShown').value; $('someKW').removeClass('displayNone'); $('noKW').addClass('displayNone'); noResultsFound(); } else { $('noKW').removeClass('displayNone'); $('someKW').addClass('displayNone'); } } EOL.jobHistory.expandJobHistoryIfRequested = function(){ var h = window.location.hash; if(h.match(/#experience_/)) { var experience = h.replace('#experience_',''); if(experience >= 0) { EOL.jobHistory.jobDetailsShow(true, experience); EOL.jobHistory.jobDetailsSectionShow(true, experience); } } } function highlightKeywordsOnPage(){ $('noresults').addClass('displayNone'); var keyword_found = false; var numJobs = EOL.jobHistory.jobList.length; for(var j=0; j b ) return -1; if ( a < b ) return 1; return 0; } function compareGT(x, y) { if(!isNaN( y[1]) && !isNaN( x[1] )) { a = parseInt(y[1]);b = parseInt(x[1]); } else { a = y[1]; b = x[1];} if ( a < b ) return -1; if ( a > b ) return 1; return 0; } function sortByOrder(A, order) { if(order == 'asc'){A.sort(compareLT) } else { A.sort(compareGT)} return A;} function unhighlightIndex(jh_index) { var node = $("experience_"+jh_index); unhighlight(node) } function unhighlight(node) { // Iterate into this nodes childNodes if (node.hasChildNodes) { var hi_cn; for (hi_cn=0;hi_cn]*)?<"; var regex = new RegExp(expression,"ig"); if(highlightTextNodes(textContainerNode, regex)){ containsKW = true; } //searchInfo += ' '+searchTerms[i]+' '; } var expeNode = $('experience_'+jh_index).parentNode; if(containsKW && !EOL.jobHistory.isExperienceFiltered(jh_index)){ // $(expeNode).removeClass('displayNone'); EOL.jobHistory.jobList[jh_index].keyword = true; } else { // $(expeNode).addClass('displayNone'); EOL.jobHistory.jobList[jh_index].keyword = false; } return containsKW; } function highlightTextNodes(element, regex) { var tempinnerHTML = element.innerHTML; var match = tempinnerHTML.search(regex); if(match > 0){ element.innerHTML = tempinnerHTML.replace(regex,'>$1$2$3<'); //tempinnerHTML.replace(regex,function(){ EOL.jobHistory.keywordCount++;}); return true; } else { return false; } } EOL.namespace('feedback'); EOL.feedback.dialog = null; EOL.feedback.respondToFeedback = function(bidid) { var request = new Request({ url: '/php/feedback/main/feedbackProviderAHR.php?bidid='+escape(bidid)+'&action=response'+'&t=' + getDateTime(), method: 'get', onSuccess: function(req) { EOL.feedback.feedbackRespond(req); }, onFailure: function() {} }).send(); } EOL.feedback.submitFeedback = function(bidid) { var postData = $('feedback_form').toQueryString(); var options = { url: '/php/feedback/main/feedbackProviderAHR.php?bidid='+escape(bidid)+'&action=submitresponse'+'&t=' + getDateTime(), method: 'post', data: postData, onSuccess: function(response) { EOL.feedback.feedbackSubmitted(response); }, onFailure: function() {alert('There was an error processing your request. Please try again.')} }; var req = new Request(options); req.send(); } EOL.feedback.close = function() { EOL.feedback.dialog.hide(); } EOL.feedback.feedbackSubmitted = function(req) { EOL.feedback.close(); EOL.feedback.dialog = new EOL.dialog(req, {position: 'fixed', modal:true, width: 450, close:true}); EOL.feedback.dialog.show(); return; } EOL.feedback.feedbackRespond = function(req) { EOL.feedback.dialog = new EOL.dialog(req, {position: 'fixed', modal:true, width: 450, close:true}); EOL.feedback.dialog.show(); $('feedback_response').focus(); return; } EOL.feedback.feedbackRequest = function(bidid) { var request = new Request({ url: '/php/feedback/main/feedbackProviderAHR.php?bidid='+escape(bidid)+'&action=request'+'&t=' + getDateTime(), method: 'get', onSuccess: function(req) { EOL.feedback.feedbackRespond(req); }, onFailure: function() {} }).send(); } EOL.feedback.submitFeedbackRequest = function(bidid) { var postData = $('feedback_form').toQueryString(); var options = { url: '/php/feedback/main/feedbackProviderAHR.php?bidid='+escape(bidid)+'&action=submitrequest'+'&t=' + getDateTime(), method: 'post', data: postData, onSuccess: function(response) { EOL.feedback.feedbackSubmitted(response); }, onFailure: function() {alert('There was an error processing your request. Please try again.')} }; var req = new Request(options); req.send(); } Fx.Elements=new Class({Extends:Fx.CSS,initialize:function(b,a){this.elements=this.subject=$$(b);this.parent(a)},compute:function(g,h,j){var c={};for(var d in g){var a=g[d],e=h[d],f=c[d]={};for(var b in a){f[b]=this.parent(a[b],e[b],j)}}return c},set:function(b){for(var c in b){if(!this.elements[c]){continue}var a=b[c];for(var d in a){this.render(this.elements[c],d,a[d],this.options.unit)}}return this},start:function(c){if(!this.check(c)){return this}var h={},j={};for(var d in c){if(!this.elements[d]){continue}var f=c[d],a=h[d]={},g=j[d]={};for(var b in f){var e=this.prepare(this.elements[d],b,f[b]);a[b]=e.from;g[b]=e.to}}return this.parent(h,j)}});Fx.Accordion=new Class({Extends:Fx.Elements,options:{fixedHeight:false,fixedWidth:false,display:0,show:false,height:true,width:false,opacity:true,alwaysHide:false,trigger:"click",initialDisplayFx:true,resetHeight:true},initialize:function(){var g=function(h){return h!=null};var f=Array.link(arguments,{container:Type.isElement,options:Type.isObject,togglers:g,elements:g});this.parent(f.elements,f.options);var b=this.options,e=this.togglers=$$(f.togglers);this.previous=-1;this.internalChain=new Chain();if(b.alwaysHide){this.options.link="chain"}if(b.show||this.options.show===0){b.display=false;this.previous=b.show}if(b.start){b.display=false;b.show=false}var d=this.effects={};if(b.opacity){d.opacity="fullOpacity"}if(b.width){d.width=b.fixedWidth?"fullWidth":"offsetWidth"}if(b.height){d.height=b.fixedHeight?"fullHeight":"scrollHeight"}for(var c=0,a=e.length;c=0?a-1:0)).chain(d)}else{d()}return this},detach:function(b){var a=function(c){c.removeEvent(this.options.trigger,c.retrieve("accordion:display"))}.bind(this);if(!b){this.togglers.each(a)}else{a(b)}return this},display:function(b,c){if(!this.check(b,c)){return this}var h={},g=this.elements,a=this.options,f=this.effects;if(c==null){c=true}if(typeOf(b)=="element"){b=g.indexOf(b)}if(b==this.previous&&!a.alwaysHide){return this}if(a.resetHeight){var e=g[this.previous];if(e&&!this.selfHidden){for(var d in f){e.setStyle(d,e[f[d]])}}}if((this.timer&&a.link=="chain")||(b===this.previous&&!a.alwaysHide)){return this}this.previous=b;this.selfHidden=false;g.each(function(l,k){h[k]={};var j;if(k!=b){j=true}else{if(a.alwaysHide&&((l.offsetHeight>0&&a.height)||l.offsetWidth>0&&a.width)){j=true;this.selfHidden=true}}this.fireEvent(j?"background":"active",[this.togglers[k],l]);for(var m in f){h[k][m]=j?0:l[f[m]]}if(!c&&!j&&a.resetHeight){h[k].height="auto"}},this);this.internalChain.clearChain();this.internalChain.chain(function(){if(a.resetHeight&&!this.selfHidden){var i=g[b];if(i){i.setStyle("height","auto")}}}.bind(this));return c?this.start(h):this.set(h).internalChain.callChain()}});var Accordion=new Class({Extends:Fx.Accordion,initialize:function(){this.parent.apply(this,arguments);var a=Array.link(arguments,{container:Type.isElement});this.container=a.container},addSection:function(c,b,e){c=document.id(c);b=document.id(b);var d=this.togglers.contains(c);var a=this.togglers.length;if(a&&(!d||e)){e=e!=null?e:a-1;c.inject(this.togglers[e],"before");b.inject(c,"after")}else{if(this.container&&!d){c.inject(this.container);b.inject(this.container)}}return this.parent.apply(this,arguments)}});(function(){Fx.Scroll=new Class({Extends:Fx,options:{offset:{x:0,y:0},wheelStops:true},initialize:function(c,b){this.element=this.subject=document.id(c);this.parent(b);if(typeOf(this.element)!="element"){this.element=document.id(this.element.getDocument().body)}if(this.options.wheelStops){var d=this.element,e=this.cancel.pass(false,this);this.addEvent("start",function(){d.addEvent("mousewheel",e)},true);this.addEvent("complete",function(){d.removeEvent("mousewheel",e)},true)}},set:function(){var b=Array.flatten(arguments);if(Browser.firefox){b=[Math.round(b[0]),Math.round(b[1])]}this.element.scrollTo(b[0],b[1]);return this},compute:function(d,c,b){return[0,1].map(function(e){return Fx.compute(d[e],c[e],b)})},start:function(c,d){if(!this.check(c,d)){return this}var b=this.element.getScroll();return this.parent([b.x,b.y],[c,d])},calculateScroll:function(g,f){var d=this.element,b=d.getScrollSize(),h=d.getScroll(),j=d.getSize(),c=this.options.offset,i={x:g,y:f};for(var e in i){if(!i[e]&&i[e]!==0){i[e]=h[e]}if(typeOf(i[e])!="number"){i[e]=b[e]-j[e]}i[e]+=c[e]}return[i.x,i.y]},toTop:function(){return this.start.apply(this,this.calculateScroll(false,0))},toLeft:function(){return this.start.apply(this,this.calculateScroll(0,false))},toRight:function(){return this.start.apply(this,this.calculateScroll("right",false))},toBottom:function(){return this.start.apply(this,this.calculateScroll(false,"bottom"))},toElement:function(d,e){e=e?Array.from(e):["x","y"];var c=a(this.element)?{x:0,y:0}:this.element.getScroll();var b=Object.map(document.id(d).getPosition(this.element),function(g,f){return e.contains(f)?g+c[f]:false});return this.start.apply(this,this.calculateScroll(b.x,b.y))},toElementEdge:function(d,g,e){g=g?Array.from(g):["x","y"];d=document.id(d);var i={},f=d.getPosition(this.element),j=d.getSize(),h=this.element.getScroll(),b=this.element.getSize(),c={x:f.x+j.x,y:f.y+j.y};["x","y"].each(function(k){if(g.contains(k)){if(c[k]>h[k]+b[k]){i[k]=c[k]-b[k]}if(f[k]this.options.snap){this.cancel();this.document.addEvents({mousemove:this.bound.drag,mouseup:this.bound.stop});this.fireEvent("start",[this.element,a]).fireEvent("snap",this.element)}},drag:function(b){var a=this.options;if(a.preventDefault){b.preventDefault()}this.mouse.now=b.page;for(var c in a.modifiers){if(!a.modifiers[c]){continue}this.value.now[c]=this.mouse.now[c]-this.mouse.pos[c];if(a.invert){this.value.now[c]*=-1}if(a.limit&&this.limit[c]){if((this.limit[c][1]||this.limit[c][1]===0)&&(this.value.now[c]>this.limit[c][1])){this.value.now[c]=this.limit[c][1]}else{if((this.limit[c][0]||this.limit[c][0]===0)&&(this.value.now[c]d.left&&b.xd.top)},this).getLast();if(this.overed!=a){if(this.overed){this.fireEvent("leave",[this.element,this.overed])}if(a){this.fireEvent("enter",[this.element,a])}this.overed=a}},drag:function(a){this.parent(a);if(this.options.checkDroppables&&this.droppables.length){this.checkDroppables()}},stop:function(a){this.checkDroppables();this.fireEvent("drop",[this.element,this.overed,a]);this.overed=null;return this.parent(a)}});Element.implement({makeDraggable:function(a){var b=new Drag.Move(this,a);this.store("dragger",b);return b}});(function(){var a=function(d){var b=d.options.hideInputs;if(window.OverText){var c=[null];OverText.each(function(e){c.include("."+e.options.labelClass)});if(c){b+=c.join(", ")}}return(b)?d.element.getElements(b):null};Fx.Reveal=new Class({Extends:Fx.Morph,options:{link:"cancel",styles:["padding","border","margin"],transitionOpacity:!Browser.ie6,mode:"vertical",display:function(){return this.element.get("tag")!="tr"?"block":"table-row"},opacity:1,hideInputs:Browser.ie?"select, input, textarea, object, embed":null},dissolve:function(){if(!this.hiding&&!this.showing){if(this.element.getStyle("display")!="none"){this.hiding=true;this.showing=false;this.hidden=true;this.cssText=this.element.style.cssText;var d=this.element.getComputedSize({styles:this.options.styles,mode:this.options.mode});if(this.options.transitionOpacity){d.opacity=this.options.opacity}var c={};Object.each(d,function(f,e){c[e]=[f,0]});this.element.setStyles({display:Function.from(this.options.display).call(this),overflow:"hidden"});var b=a(this);if(b){b.setStyle("visibility","hidden")}this.$chain.unshift(function(){if(this.hidden){this.hiding=false;this.element.style.cssText=this.cssText;this.element.setStyle("display","none");if(b){b.setStyle("visibility","visible")}}this.fireEvent("hide",this.element);this.callChain()}.bind(this));this.start(c)}else{this.callChain.delay(10,this);this.fireEvent("complete",this.element);this.fireEvent("hide",this.element)}}else{if(this.options.link=="chain"){this.chain(this.dissolve.bind(this))}else{if(this.options.link=="cancel"&&!this.hiding){this.cancel();this.dissolve()}}}return this},reveal:function(){if(!this.showing&&!this.hiding){if(this.element.getStyle("display")=="none"){this.hiding=false;this.showing=true;this.hidden=false;this.cssText=this.element.style.cssText;var d;this.element.measure(function(){d=this.element.getComputedSize({styles:this.options.styles,mode:this.options.mode})}.bind(this));if(this.options.heightOverride!=null){d.height=this.options.heightOverride.toInt()}if(this.options.widthOverride!=null){d.width=this.options.widthOverride.toInt()}if(this.options.transitionOpacity){this.element.setStyle("opacity",0);d.opacity=this.options.opacity}var c={height:0,display:Function.from(this.options.display).call(this)};Object.each(d,function(f,e){c[e]=0});c.overflow="hidden";this.element.setStyles(c);var b=a(this);if(b){b.setStyle("visibility","hidden")}this.$chain.unshift(function(){this.element.style.cssText=this.cssText;this.element.setStyle("display",Function.from(this.options.display).call(this));if(!this.hidden){this.showing=false}if(b){b.setStyle("visibility","visible")}this.callChain();this.fireEvent("show",this.element)}.bind(this));this.start(d)}else{this.callChain();this.fireEvent("complete",this.element);this.fireEvent("show",this.element)}}else{if(this.options.link=="chain"){this.chain(this.reveal.bind(this))}else{if(this.options.link=="cancel"&&!this.showing){this.cancel();this.reveal()}}}return this},toggle:function(){if(this.element.getStyle("display")=="none"){this.reveal()}else{this.dissolve()}return this},cancel:function(){this.parent.apply(this,arguments);if(this.cssText!=null){this.element.style.cssText=this.cssText}this.hiding=false;this.showing=false;return this}});Element.Properties.reveal={set:function(b){this.get("reveal").cancel().setOptions(b);return this},get:function(){var b=this.retrieve("reveal");if(!b){b=new Fx.Reveal(this);this.store("reveal",b)}return b}};Element.Properties.dissolve=Element.Properties.reveal;Element.implement({reveal:function(b){this.get("reveal").setOptions(b).reveal();return this},dissolve:function(b){this.get("reveal").setOptions(b).dissolve();return this},nix:function(b){var c=Array.link(arguments,{destroy:Type.isBoolean,options:Type.isObject});this.get("reveal").setOptions(b).dissolve().chain(function(){this[c.destroy?"destroy":"dispose"]()}.bind(this));return this},wink:function(){var c=Array.link(arguments,{duration:Type.isNumber,options:Type.isObject});var b=this.get("reveal").setOptions(c.options);b.reveal().chain(function(){(function(){b.dissolve()}).delay(c.duration||2000)})}})})();Fx.Move=new Class({Extends:Fx.Morph,options:{relativeTo:document.body,position:"center",edge:false,offset:{x:0,y:0}},start:function(a){var b=this.element,c=b.getStyles("top","left");if(c.top=="auto"||c.left=="auto"){b.setPosition(b.getPosition(b.getOffsetParent()))}return this.parent(b.position(Object.merge({},this.options,a,{returnPos:true})))}});Element.Properties.move={set:function(a){this.get("move").cancel().setOptions(a);return this},get:function(){var a=this.retrieve("move");if(!a){a=new Fx.Move(this,{link:"cancel"});this.store("move",a)}return a}};Element.implement({move:function(a){this.get("move").start(a);return this}}); /* --- description: CwCrop authors: - Mario Fischer (http://www.chipwreck.de/blog/) license: - MIT-style license requires: core/1.2.3: '*' more/1.2.3: 'Drag.*' provides: - CwCrop version: 0.95 ... */ CwCrop = new Class({ Implements: [Options,Events], options: { minsize: {x: 60, y: 60}, // minimal size of the resulting image maxsize: {x: 200, y: 200}, // maximal size of the resulting image originalsize: {x: 1, y: 1}, // size of the original image (if the crop area uses a smaller version) fixedratio: false, // if set to a number, use this as a fixed ratio (and ignore maxratio) maxratio: {x: 2, y: 2}, // maximum ratio x, y initialposition: {x: 10, y: 10}, // initial position (in the crop area) initialmax: false, // extend the crop area initially to the maximum size classactive: "active", // css classname for the crop frame if the user moves/resizes cropframe: "cropframe", // css id of the crop frame imgframe: "imglayer", // css id of the image frame cropdims: "cropdims", // css id for the crop dimensions (leave empty to disable showing dimensions) cropbtn: "cropbtn", // css id for an addition button (leave empty to disable) draghandle: "draghandle", // css id for the dragging handle resizehandle: "resizeHandleXY", // css id for the resizing handle onCrop: function() {} // function to execute if the user crops }, initialize: function(options) { this.setOptions(options); if (!$(this.options.cropframe) || !$(this.options.imgframe)) { return; } // calc initial limits and scaling this.elemsize = $(this.options.imgframe).getSize(); if (this.elemsize.x === 0) { this.elemsize = $(this.options.imgframe).getOffsetParent().getSize(); } this.orig_to_scaled = {x: 1, y: 1}; if (this.options.originalsize.x > 1 && this.options.originalsize.y > 1) { this.orig_to_scaled.x = this.options.originalsize.x / this.elemsize.x; this.orig_to_scaled.y = this.options.originalsize.y / this.elemsize.y; } this.options.maxsize.x = ( this.options.maxsize.x * (1/this.orig_to_scaled.x) ).limit(1, this.elemsize.x-2); this.options.maxsize.y = ( this.options.maxsize.y * (1/this.orig_to_scaled.y) ).limit(1, this.elemsize.y-2); this.options.minsize.x = ( this.options.minsize.x * (1/this.orig_to_scaled.x) ).limit(1, this.elemsize.x-2); this.options.minsize.y = ( this.options.minsize.y * (1/this.orig_to_scaled.y) ).limit(1, this.elemsize.y-2); this.limits = { x:[this.options.minsize.x, this.options.maxsize.x], y:[this.options.minsize.y, this.options.maxsize.y] }; // init crop frame if (this.options.initialmax) { $(this.options.cropframe).setStyle("top", 0); $(this.options.cropframe).setStyle("left", 0); $(this.options.cropframe).setStyle("width", this.limits.x[1].toInt()); $(this.options.cropframe).setStyle("height", this.limits.y[1].toInt()); } else { $(this.options.cropframe).setStyle("top", this.options.initialposition.y); $(this.options.cropframe).setStyle("left", this.options.initialposition.x); $(this.options.cropframe).setStyle("width", this.limits.x[0].toInt()); $(this.options.cropframe).setStyle("height", this.limits.y[0].toInt()); } if (this.options.fixedratio) { $(this.options.cropframe).setStyle("width", $(this.options.cropframe).getStyle("height").toInt() * this.options.fixedratio); } this.updateCropDims($(this.options.cropframe)); this.recalcResize($(this.options.cropframe)); this.myMove = new Drag.Move($(this.options.cropframe), { style: true, precalculate: true, snap: 1, grid: false, container: $(this.options.imgframe), includeMargins: true, checkDroppables: false, handle: $(this.options.draghandle), onStart: function(el) { el.addClass(this.options.classactive); }.bind(this), onDrag: function(el) { this.moveBgImage(el); this.updateCropDims(el, true); }.bind(this), onComplete: function(el) { el.removeClass(this.options.classactive); this.updateCropDims(el); this.recalcResize(el); }.bind(this) }); this.moveBgImage($(this.options.cropframe)); this.myResizeXY = $(this.options.cropframe).makeResizable({ style: true, precalculate: true, snap: 1, grid: false, handle: $(this.options.resizehandle), limit: this.limits, onStart: function(el) { el.addClass(this.options.classactive); }.bind(this), onDrag: function(el, event) { this.checkRatio(el, event); this.updateCropDims(el); }.bind(this), onComplete: function(el) { el.removeClass(this.options.classactive); }.bind(this) }); if ($(this.options.cropbtn)) { $(this.options.cropbtn).addEvent('click', function() { this.doCrop(); }.bind(this)); } }, createHtml: function(el, imgname) { /*
*/ }, moveBgImage: function(el) { el.setStyle("background-position","-" + (el.getStyle("left").toInt()) + "px " + "-" + (el.getStyle("top").toInt()) + "px"); }, checkRatio: function(el, event) { var newwidth = 0; var newheight = 0; var ratio = el.getStyle("width").toInt() / el.getStyle("height").toInt(); if (this.options.fixedratio) { if (ratio != this.options.fixedratio) { newwidth = el.getStyle("height").toInt() * this.options.fixedratio; } } else if (event.shift && ( (!this.options.maxratio.x && !this.options.maxratio.y) || (!this.options.maxratio.x && this.options.maxratio.y >= 1) || (this.options.maxratio.x >= 1 && !this.options.maxratio.y) || (this.options.maxratio.x >= 1 && this.options.maxratio.y >= 1) )) { if (ratio > 1) { newwidth = el.getStyle("height").toInt(); } else if (ratio < 1) { newheight = el.getStyle("width").toInt(); } } else { if (ratio > 1 && ratio > this.options.maxratio.x) { newwidth = el.getStyle("height").toInt() * this.options.maxratio.x; } else if (ratio < 1 && ratio < (1/this.options.maxratio.y)) { newheight = el.getStyle("width").toInt() * this.options.maxratio.y; } } if (newwidth > this.limits.x[0] && newwidth < this.limits.x[1]) { el.setStyle("width", newwidth); } else if (newheight > this.limits.y[0] && newheight < this.limits.y[1]) { el.setStyle("height", newheight); } else if (this.options.fixedratio && ratio != this.options.fixedratio) { el.setStyle("height", el.getStyle("width").toInt() / this.options.fixedratio); } }, recalcResize: function(el) { this.limits.x[1] = this.elemsize.x - ( el.getStyle("left").toInt() ) - 2; this.limits.y[1] = this.elemsize.y - ( el.getStyle("top").toInt() ) - 2; this.limits.x[1] = Math.round( Math.min( this.limits.x[1], this.options.maxsize.x ) ); this.limits.y[1] = Math.round( Math.min( this.limits.y[1], this.options.maxsize.y ) ); if (this.myResizeXY) { this.myResizeXY.options.limit = this.limits; } }, updateCropDims: function(el, displayPosition) { if (!$(this.options.cropdims)) { return; } if (displayPosition) { xresized = Math.round( el.getStyle("left").toInt() * this.orig_to_scaled.x ); yresized = Math.round( el.getStyle("top").toInt() * this.orig_to_scaled.y ); out = xresized + ", " + yresized; } else { xresized = Math.round( el.getStyle("width").toInt() * this.orig_to_scaled.x ); yresized = Math.round( el.getStyle("height").toInt() * this.orig_to_scaled.y ); out = xresized + " x " + yresized; } $(this.options.cropdims).set('html', out); }, doCrop: function() { var el = $(this.options.cropframe); var x = Math.round( el.getStyle("left").toInt() * this.orig_to_scaled.x ); var y = Math.round( el.getStyle("top").toInt() * this.orig_to_scaled.y ); var w = Math.round( el.getStyle("width").toInt() * this.orig_to_scaled.x ); var h = Math.round( el.getStyle("height").toInt() * this.orig_to_scaled.y ); if (x >= 0 && y >= 0 && h >= this.options.minsize.y && w >= this.options.minsize.x) { this.fireEvent('onCrop',{'x':x,'y':y,'w':w,'h':h}); } } }); EOL.namespace('profileImage'); // vars EOL.profileImage.uploading = false; EOL.profileImage.cropObj = null; /* Upload listener */ EOL.profileImage.addUploadListner = function() { if ($("uploadImageTarget")) { //alert('Adding event'); $("uploadImageTarget").addEvent('load', function() { if (!EOL.profileImage.uploading) return; try { var response = JSON.decode($("uploadImageTarget").contentWindow.document.body.innerHTML); } catch(e) { alert('There was an error processing your request. Please refresh and try again.'); } if (response) { //alert('in here 1'); EOL.profileImage.cropObj = null; if( response.status == 'success' && response.data) { $('imageMode').value = 'new'; var displayImage = response.data.profileImgDraftThumbData.url; /* Preview and save related setters */ $("tilePreview").src = displayImage; $("thumbPreview1").src = displayImage; $("thumbPreview2").src = displayImage; // set proper thumb preview block if($("existingThumbPreview")) { $("existingThumbPreview").style.display = 'none'; } $("cropThumbPreview").style.display = 'none'; $("fullThumbPreview").style.display = ''; $('groupId').value = response.data.groupId; $('saveSection').style.display = ''; $('loadingIcon').style.display = 'none'; $('previewArea').style.display = ''; /* Crop related setters */ $('cropframe').style.backgroundImage = "url('" + displayImage + "')"; var imglayer = $('imglayer'); imglayer.setStyle('background-image', "url('" + displayImage + "')"); imglayer.setStyle('width', response.data.profileImgDraftThumbData.width); imglayer.setStyle('height', response.data.profileImgDraftThumbData.height); $('scaleToFitImage').src = displayImage; // Hide any Error messages $('imageSaveError').style.display = 'none'; $('imageDeleteError').style.display = 'none'; $('imageDraftError').style.display = 'none'; //enable 'set ad my profile picture' button $('setButton').addClass('btn-large-normal'); $('setButton').removeClass('btn-large-disabled'); //Initializing the crop object is done when the crop area is displayed. because of the offsetParent requires the elements to be visible. } else if( response.status == 'error' ) { EOL.profileImage.handleUploadErrors(response); } enableElems($('save-action-buttons')); } else { alert('There was an error processing your request. Please refresh and try again.'); } EOL.profileImage.uploading = false; }); } } EOL.profileImage.handleUploadErrors = function(res) { var errorArr = res.errorMsgs; $('imageDraftErrMsg').innerHTML = ''; for( var i = 0; i < errorArr.length; i++ ) { //alert(errorArr[i] + '-' + errorArr[i].indexOf('435')); if(errorArr[i].indexOf('435') >= 0) $('imageDraftErrMsg').innerHTML += '
  • Selected file type is not supported. Please use jpeg, gif or png file.
  • '; else $('imageDraftErrMsg').innerHTML += '
  • ' + errorArr[i] + '
  • '; } $('imageDraftError').style.display = ''; $('saveSection').style.display = 'none'; } /* END- Upload listener */ /* Dialog */ EOL.profileImage.dialog = null; EOL.profileImage.open = function(context) { //alert('test'); EOL.profileImage.cropObj = null; var request = new Request({ url: '/php/profile/main/profileImageUploadHTML.php?context=' + context + '&t=' + getDateTime(), method: 'get', onSuccess: function(req) { addCSS('/styles/profile/profileImageUpload.css'); EOL.profileImage.dialog = new EOL.dialog(req, {id:'imageUploadDialog', position: 'fixed', modal:true, close:true}); EOL.profileImage.dialog.show(); EOL.profileImage.addUploadListner(); }, onFailure: function() {} }).send(); } EOL.profileImage.close = function() { EOL.profileImage.dialog.hide(); } /* END- Dialog */ /* Interaction actions */ EOL.profileImage.toggleUploadAndCropSection = function() { if($('cropSection').style.display != '') { $('cropSection').style.display = ''; $('uploadAndSaveSection').style.display = 'none'; // cwCrop Object needs to be initialzed when the crop divs are not display:none i.e. they are visible. Firefox and chrome does not return offsetParent if the elements are display:none if(!EOL.profileImage.cropObj) { EOL.profileImage.initializeCropObj(); } } else { $('cropSection').style.display = 'none'; $('uploadAndSaveSection').style.display = ''; } } EOL.profileImage.initializeCropObj = function() { //alert('initializing crop'); EOL.profileImage.cropObj = new CwCrop({ onCrop: function(values) { //alert('On crop called'); $('cropX').value = values.x; $('cropY').value = values.y; $('cropWidth').value = values.w; $('cropHeight').value = values.h; //alert("Selected area is: " + values.x + "," + values.y + " @ " + values.w + " x " + values.h); }, minsize: {x: 64, y: 80}, initialposition: {x: 30, y: 30}, imgframe: "imglayer", fixedratio: 0.8 }); } EOL.profileImage.handleScaleToFitToggle = function() { var scaleToFit = $$('input[type=checkbox][name=scaleToFit]')[0]; if(scaleToFit.checked == true) { $('cropArea').setStyle('display', 'none'); $('scaleToFitArea').setStyle('display', ''); } else { $('scaleToFitArea').setStyle('display', 'none'); $('cropArea').setStyle('display', ''); } } EOL.profileImage.handlePrepareThumbAction = function() { var scaleToFit = $$('input[type=checkbox][name=scaleToFit]')[0]; if($('existingThumbPreview')) { $('existingThumbPreview').setStyle('display', 'none'); } if(scaleToFit.checked == true) { $('thumbMode').value = 'full'; $('cropThumbPreview').setStyle('display', 'none'); $('fullThumbPreview').setStyle('display', ''); } else { EOL.profileImage.handleCropAction(); $('thumbMode').value = 'crop'; //set the display of cropped thumb var magnifyRatio = $('cropWidth').value/64; //alert('magnifyRatio' + magnifyRatio ); //alert($('imglayer').getStyle('width') + '-' +$('imglayer').getStyle('height')); var cropThumbW = (parseFloat($('imglayer').getStyle('width')))/magnifyRatio; var cropThumbH = (parseFloat($('imglayer').getStyle('height')))/magnifyRatio; var marginLeft = -Math.round(parseFloat($('cropX').value)/magnifyRatio); var marginTop = -Math.round(parseFloat($('cropY').value)/magnifyRatio); var thumbPreview2 = $('thumbPreview2'); //alert('cropThumbW-' + cropThumbW + '-' + 'cropThumbH-' + cropThumbH + '-marginLeft' + marginLeft + '-marginTop' + marginTop); thumbPreview2.setStyle('width', cropThumbW); thumbPreview2.setStyle('height', cropThumbH); thumbPreview2.setStyle('margin-left', marginLeft); thumbPreview2.setStyle('margin-top', marginTop); $('fullThumbPreview').setStyle('display', 'none'); $('cropThumbPreview').setStyle('display', ''); } EOL.profileImage.toggleUploadAndCropSection(); } EOL.profileImage.handleCropAction = function() { EOL.profileImage.cropObj.doCrop(); } /* END - Interaction actions */ /* AHRs */ EOL.profileImage.handleCreateDraft = function() { EOL.profileImage.uploading = true; disableElems($('save-action-buttons')); $('setButton').addClass('btn-large-disabled'); $('setButton').removeClass('btn-large-normal'); /* flip loading image and preview area */ $('loadingIcon').style.display = ''; $('previewArea').style.display = 'none'; /* END FLIP */ $('imageDraftError').style.display = 'none'; $('imageDraftForm').submit(); } // Save Image EOL.profileImage.handleSaveImage = function() { $('imageDraftError').style.display = 'none'; var postData = $('imageSaveForm').toQueryString(); disableElems($('save-action-buttons')); $('setButton').addClass('btn-large-disabled'); $('setButton').removeClass('btn-large-normal'); var options = { url: '/php/profile/main/profileImageUploadAHR.php?t=' + getDateTime(), method: 'post', data: postData, onSuccess: EOL.profileImage.handleSaveImageSuccess, onFailure: function() { alert('There was an error processing your request. Please refresh and try again.'); } }; curAsyncReq = new Request(options); curAsyncReq.send(); } EOL.profileImage.handleSaveImageSuccess = function( obj ) { //-- read JSON data var response = eval('(' + obj + ')'); if( response.status == 'success' ) { if($('profileImage') && response.data.profileUrl) { $('profileImage').src = response.data.profileUrl; enableElems($('save-action-buttons')); $('setButton').addClass('btn-large-normal'); $('setButton').removeClass('btn-large-disabled'); EOL.profileImage.dialog.hide(); } else { var current = document.location.href; if(current.indexOf("?pledge=taken") > 0){ var redirectTo = current.replace('?pledge=taken',''); window.location = redirectTo; }else window.location = window.location.href.split('#')[0]; } } else if( response.status == 'error' ) { disableElems($('save-action-buttons')); $('setButton').addClass('btn-large-disabled'); $('setButton').removeClass('btn-large-normal'); var errorArr = response.errorMsgs; $('imageSaveErrMsg').innerHTML = ''; for( var i = 0; i < errorArr.length; i++ ) { $('imageSaveErrMsg').innerHTML += '
  • ' + errorArr[i] + '
  • '; } $('imageSaveError').style.display = ''; } } // Delete Image EOL.profileImage.handleDeleteImageAction = function() { var options = { url: '/php/profile/main/profileImageUploadAHR.php?mode=DeleteImage&context=' + $('context').value + '&t=' + getDateTime(), method: 'post', onSuccess: EOL.profileImage.handleDeleteImageSuccess, onFailure: function() { alert('There was an error processing your request. Please refresh and try again.'); } }; curAsyncReq = new Request(options); curAsyncReq.send(); } EOL.profileImage.handleDeleteImageSuccess = function( obj ) { var response = eval('(' + obj + ')'); if( response.status == 'success' ) { //refresh the entire page to update state of other components window.location.href = window.location.href.replace('#',''); return; } else if(response.status == 'error') { var errorArr = response.errorMsgs; $('imageDeleteErrMsg').innerHTML = ''; for( var i = 0; i < errorArr.length; i++ ) { $('imageDeleteErrMsg').innerHTML += '
  • ' + errorArr[i] + '
  • '; } $('imageDeleteError').style.display = ''; } } /* END- AHRs */